package com.lijie.springcloud.controller;

import com.lijie.springcloud.entries.Payment;
import com.lijie.springcloud.entries.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Title: springCloudStudy
 * @Description: ()
 * @Author:lijie
 * @Version:1.1.0
 * @since 2022/2/9
 */
@Slf4j
@RestController
@RequestMapping("/consumer/order")
public class OrderController {
    @Resource
    RestTemplate restTemplate;
    private  static final String PAYMENT_URL="http://localhost:8001";

    @GetMapping("/getOrderById/{id}")
    public Result<Payment> getPayment(@PathVariable Integer id){
        return restTemplate.getForObject(PAYMENT_URL + "/provider/payment/getById/" + id, Result.class);
    }
    @GetMapping("/create")
    public Result<Payment> getPayment(Payment payment){
        return restTemplate.postForObject(PAYMENT_URL+"/provider/payment/create",payment,Result.class);
    }
}
